#ifndef SHARE_RECV_PROCESS_H
#define SHARE_RECV_PROCESS_H

#include <vector>
#include <string>
#include <functional>

class ShareRecvProcess {
public:
    explicit ShareRecvProcess(std::function<void(const char*)> deleteShareName)
        : m_deleteShareName(deleteShareName),
          m_format(0),
          m_dataLen(0),
          m_textHeader({0}),
          m_isHTMLShare(FALSE) { }
    ~ShareRecvProcess();
    PBYTE GetData();
    SIZE_T GetDataLen();
    DWORD GetFormat();
    PBYTE Resize(SIZE_T len);
    BOOL CheckExtraHeader();
    void Clear();
    BOOL PrepareData();
    PBYTE GetUnicodeData();
    SIZE_T GetUnicodeLen();
    PBYTE GetHTMLData();
    SIZE_T GetHTMLLen();
    BOOL CheckHeader(ShareHeader *header);
    LPCSTR GetFileListShareName() { return m_fileListShareName.c_str(); }

private:
    BOOL CheckCrc(ShareHeader *header);
    BOOL PrepareText();
    BOOL BasicHeaderCheck(ShareHeader *header);
    BOOL FormatSpecificCheck(ShareHeader *header);
    DWORD m_format;
    SIZE_T m_dataLen;
    TextHeader m_textHeader;
    std::string m_fileListShareName;
    std::string m_htmlShareName;
    std::vector<BYTE> m_data;
    std::vector<WCHAR> m_unicodeText;
    std::vector<BYTE> m_htmlData;
    BOOL m_isHTMLShare;
    std::function<void(const char*)> m_deleteShareName;
};

#endif // SHARE_RECV_PROCESS_H
